import java.util.Arrays;

public class TestRotate {
    public static void rotate1(int[] nums, int k) {
//        while(k>0){
            for(int i=0;i<nums.length;i++){
                int tmp1 = nums[i];
                int tmp2 = nums[(i+1)%nums.length];
                nums[(i+1)%nums.length] = tmp1;
            }
//            k--;
//        }
    }

    public static void rotate2(int[] nums, int k){
        int[] tmp = Arrays.copyOf(nums,nums.length);
        for (int i = 0; i < nums.length; i++) {
            nums[(i+k)%nums.length] = tmp[i];
        }
        for (int x : nums)
        {
            System.out.print(x+" ");
        }
    }

    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5,6,7};
        rotate2(nums,3);
//        for(int x : nums)
//        {
//            System.out.print(x+" ");
//        }
    }
}
